//
//  ColorUtil.m
//  miyue
//
//  Created by bite on 15/6/23.
//  Copyright (c) 2015年 jianfengChen. All rights reserved.
//

#import "ColorUtil.h"

@implementation ColorUtil

+ (UIColor *)collectColor {
    
    return [ColorUtil hexStringToColor:@"#595666"];
}

+(UIColor *)mainColor {
    
    return [ColorUtil hexStringToColor:@"#2174ff"];
}

+(UIColor *)tishiColor {
    
    return [ColorUtil hexStringToColor:@"#ffd800"];
}

+ (UIColor *)lineColor {
    
    return [ColorUtil hexStringToColor:@"#dcdde4"];
}

+(UIColor*)orange
{
    return [ColorUtil hexStringToColor:@"#FF7A37"];
}
+(UIColor*)white
{
    return [ColorUtil hexStringToColor:@"FFFFFF"];
}
+(UIColor*)inputGray
{
    return [ColorUtil hexStringToColor:@"#E4E5E5"];
}
+(UIColor*)gray
{
//    return [ColorUtil hexStringToColor:@"#999999"];
    return [ColorUtil hexStringToColor:@"#21212b"];

}
+(UIColor*)gray_background
{
//    return [ColorUtil hexStringToColor:@"#F4F4F4"];
    return [ColorUtil hexStringToColor:@"#f6f6f6"];

}
+(UIColor*)circleProgress
{
    return [ColorUtil hexStringToColor:@"FFE7C0"];
}
+(UIColor*)purple
{
    return [ ColorUtil hexStringToColor:@"#6861b1"];
}

+(UIColor*)blackColor
{
    return [ ColorUtil hexStringToColor:@"#040404"];
}

+(UIColor*)hexStringToColor:(NSString *)stringToConvert
{
    return  [self hexStringToColor:stringToConvert alpha:1.0f];
}
+(UIColor*)hexStringToColor:(NSString *)stringToConvert alpha:(CGFloat)alpha
{
    NSString *cString=[[stringToConvert stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]uppercaseString];
    if ([cString length]<6)return [UIColor blackColor];
    if ([cString hasPrefix:@"0X"])cString=[cString substringFromIndex:2];
    if ([cString hasPrefix:@"#"]) cString=[cString substringFromIndex:1];
    if ([cString length]!=6)return [UIColor blackColor];
    NSRange range;
    range.location=0;
    range.length=2;
    NSString *rString=[cString substringWithRange:range];range.location=2;
    NSString *gString=[cString substringWithRange:range];
    range.location=4;
    NSString *bString=[cString substringWithRange:range];
    unsigned int r,g,b;
    [[NSScanner scannerWithString:rString]scanHexInt:&r];
    [[NSScanner scannerWithString:gString]scanHexInt:&g];
    [[NSScanner scannerWithString:bString]scanHexInt:&b];
    return [UIColor colorWithRed:((float)r/255.0f) green:((float)g/255.0) blue:((float)b/255.0f) alpha:alpha];
}
+ (NSString *)changeLabelTextColor:(NSString *)labelTextString color:(id)value preStr:(NSString *)preStr endStr:(NSString *)endStr
{
    NSMutableAttributedString *tempLabelString = [[NSMutableAttributedString alloc]initWithString:labelTextString];
    NSInteger leftRange = [[tempLabelString string] rangeOfString:preStr].location;
    NSInteger rightRange = [[tempLabelString string] rangeOfString:endStr].location;
    NSRange rangeToChange = {leftRange,rightRange - leftRange + 1};
    [tempLabelString addAttribute:NSForegroundColorAttributeName value:value range:rangeToChange];
    return (NSString *)tempLabelString;
}
@end
